home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS02.ADF / Emacs / main.c < prev    next >
C/C++ Source or Header  |  1989-05-30  |  24KB  |  599 lines

  1. /* main.c */
  2.  
  3. /*
  4.  * This program is in public domain; written by Dave G. Conroy.
  5.  * This file contains the main driving routine, and some keyboard processing
  6.  * code, for the MicroEMACS screen editor.
  7.  *
  8.  * REVISION HISTORY:
  9.  *
  10.  * 1.0  Steve Wilhite, 30-Nov-85
  11.  *      - Removed the old LK201 and VT100 logic. Added code to support the
  12.  *        DEC Rainbow keyboard (which is a LK201 layout) using the the Level
  13.  *        1 Console In ROM INT. See "rainbow.h" for the function key definitions.
  14.  *
  15.  * 2.0  George Jones, 12-Dec-85
  16.  *      - Ported to Amiga.
  17.  */
  18. #include        <stdio.h>
  19. #include        "ed.h"
  20.  
  21. #if     VMS
  22. #include        <ssdef.h>
  23. #define GOOD    (SS$_NORMAL)
  24. #endif
  25.  
  26. #ifndef GOOD
  27. #define GOOD    0
  28. #endif
  29.  
  30. int     currow;                         /* Working cursor row           */
  31. int     curcol;                         /* Working cursor column        */
  32. int     fillcol;                        /* Current fill column          */
  33. int     thisflag;                       /* Flags, this command          */
  34. int     lastflag;                       /* Flags, last command          */
  35. int     curgoal;                        /* Goal column                  */
  36. BUFFER  *curbp;                         /* Current buffer               */
  37. WINDOW  *curwp;                         /* Current window               */
  38. BUFFER  *bheadp;                        /* BUFFER listhead              */
  39. WINDOW  *wheadp;                        /* WINDOW listhead              */
  40. BUFFER  *blistp;                        /* Buffer list BUFFER           */
  41. short   kbdm[NKBDM] = {CTLX|')'};       /* Macro                        */
  42. short   *kbdmip;                        /* Input  for above             */
  43. short   *kbdmop;                        /* Output for above             */
  44. char    pat[NPAT];                      /* Pattern                      */
  45.  
  46. typedef struct  {
  47.         short   k_code;                 /* Key code                     */
  48.         int     (*k_fp)();              /* Routine to handle it         */
  49. }       KEYTAB;
  50.  
  51. extern  int     ctrlg();                /* Abort out of things          */
  52. extern  int     quit();                 /* Quit                         */
  53. extern  int     ctlxlp();               /* Begin macro                  */
  54. extern  int     ctlxrp();               /* End macro                    */
  55. extern  int     ctlxe();                /* Execute macro                */
  56. extern  int     fileread();             /* Get a file, read only        */
  57. extern  int     filevisit();            /* Get a file, read write       */
  58. extern  int     filewrite();            /* Write a file                 */
  59. extern  int     filesave();             /* Save current file            */
  60. extern  int     filename();             /* Adjust file name             */
  61. extern  int     getccol();              /* Get current column           */
  62. extern  int     gotobol();              /* Move to start of line        */
  63. extern  int     forwchar();             /* Move forward by characters   */
  64. extern  int     gotoeol();              /* Move to end of line          */
  65. extern  int     backchar();             /* Move backward by characters  */
  66. extern  int     forwline();             /* Move forward by lines        */
  67. extern  int     backline();             /* Move backward by lines       */
  68. extern  int     forwpage();             /* Move forward by pages        */
  69. extern  int     backpage();             /* Move backward by pages       */
  70. extern  int     gotobob();              /* Move to start of buffer      */
  71. extern  int     gotoeob();              /* Move to end of buffer        */
  72. extern  int     setfillcol();           /* Set fill column.             */
  73. extern  int     setmark();              /* Set mark                     */
  74. extern  int     swapmark();             /* Swap "." and mark            */
  75. extern  int     forwsearch();           /* Search forward               */
  76. extern  int     backsearch();           /* Search backwards             */
  77. extern  int     showcpos();             /* Show the cursor position     */
  78. extern  int     nextwind();             /* Move to the next window      */
  79. extern  int     prevwind();             /* Move to the previous window  */
  80. extern  int     onlywind();             /* Make current window only one */
  81. extern  int     splitwind();            /* Split current window         */
  82. extern  int     mvdnwind();             /* Move window down             */
  83. extern  int     mvupwind();             /* Move window up               */
  84. extern  int     enlargewind();          /* Enlarge display window.      */
  85. extern  int     shrinkwind();           /* Shrink window.               */
  86. extern  int     listbuffers();          /* Display list of buffers      */
  87. extern  int     usebuffer();            /* Switch a window to a buffer  */
  88. extern  int     killbuffer();           /* Make a buffer go away.       */
  89. extern  int     reposition();           /* Reposition window            */
  90. extern  int     refresh();              /* Refresh the screen           */
  91. extern  int     twiddle();              /* Twiddle characters           */
  92. extern  int     tab();                  /* Insert tab                   */
  93. extern  int     newline();              /* Insert CR-LF                 */
  94. extern  int     indent();               /* Insert CR-LF, then indent    */
  95. extern  int     openline();             /* Open up a blank line         */
  96. extern  int     deblank();              /* Delete blank lines           */
  97. extern  int     quote();                /* Insert literal               */
  98. extern  int     backword();             /* Backup by words              */
  99. extern  int     forwword();             /* Advance by words             */
  100. extern  int     forwdel();              /* Forward delete               */
  101. extern  int     backdel();              /* Backward delete              */
  102. extern  int     kill();                 /* Kill forward                 */
  103. extern  int     yank();                 /* Yank back from killbuffer.   */
  104. extern  int     upperword();            /* Upper case word.             */
  105. extern  int     lowerword();            /* Lower case word.             */
  106. extern  int     upperregion();          /* Upper case region.           */
  107. extern  int     lowerregion();          /* Lower case region.           */
  108. extern  int     capword();              /* Initial capitalize word.     */
  109. extern  int     delfword();             /* Delete forward word.         */
  110. extern  int     delbword();             /* Delete backward word.        */
  111. extern  int     killregion();           /* Kill region.                 */
  112. extern  int     copyregion();           /* Copy region to kill buffer.  */
  113. extern  int     spawncli();             /* Run CLI in a subjob.         */
  114. extern  int     spawn();                /* Run a command in a subjob.   */
  115. extern  int     quickexit();            /* low keystroke style exit.    */
  116.  
  117. /*
  118.  * Command table.
  119.  * This table  is *roughly* in ASCII order, left to right across the
  120.  * characters of the command. This expains the funny location of the
  121.  * control-X commands.
  122.  */
  123. KEYTAB  keytab[] = {
  124.         CTRL|'@',               &setmark,
  125.         CTRL|'A',               &gotobol,
  126.         CTRL|'B',               &backchar,
  127.         CTRL|'C',               &spawncli,      /* Run CLI in subjob.   */
  128.         CTRL|'D',               &forwdel,
  129.         CTRL|'E',               &gotoeol,
  130.         CTRL|'F',               &forwchar,
  131.         CTRL|'G',               &ctrlg,
  132.         CTRL|'H',               &backdel,
  133.         CTRL|'I',               &tab,
  134.         CTRL|'J',               &indent,
  135.         CTRL|'K',               &kill,
  136.         CTRL|'L',               &refresh,
  137.         CTRL|'M',               &newline,
  138.         CTRL|'N',               &forwline,
  139.         CTRL|'O',               &openline,
  140.         CTRL|'P',               &backline,
  141.         CTRL|'Q',               "e,         /* Often unreachable    */
  142.         CTRL|'R',               &backsearch,
  143.         CTRL|'S',               &forwsearch,    /* Often unreachable    */
  144.         CTRL|'T',               &twiddle,
  145.         CTRL|'V',               &forwpage,
  146.         CTRL|'W',               &killregion,
  147.         CTRL|'Y',               &yank,
  148.         CTRL|'Z',               &quickexit,     /* quick save and exit  */
  149.         CTLX|CTRL|'B',          &listbuffers,
  150.         CTLX|CTRL|'C',          &quit,          /* Hard quit.           */
  151.         CTLX|CTRL|'F',          &filename,
  152.         CTLX|CTRL|'L',          &lowerregion,
  153.         CTLX|CTRL|'O',          &deblank,
  154.         CTLX|CTRL|'N',          &mvdnwind,
  155.         CTLX|CTRL|'P',          &mvupwind,
  156.         CTLX|CTRL|'R',          &fileread,
  157.         CTLX|CTRL|'S',          &filesave,      /* Often unreachable    */
  158.         CTLX|CTRL|'U',          &upperregion,
  159.         CTLX|CTRL|'V',          &filevisit,
  160.         CTLX|CTRL|'W',          &filewrite,
  161.         CTLX|CTRL|'X',          &swapmark,
  162.         CTLX|CTRL|'Z',          &shrinkwind,
  163.         CTLX|'!',               &spawn,         /* Run 1 command.       */
  164.         CTLX|'=',               &showcpos,
  165.         CTLX|'(',               &ctlxlp,
  166.         CTLX|')',               &ctlxrp,
  167.         CTLX|'1',               &onlywind,
  168.         CTLX|'2',               &splitwind,
  169.         CTLX|'B',               &usebuffer,
  170.         CTLX|'E',               &ctlxe,
  171.         CTLX|'F',               &setfillcol,
  172.         CTLX|'K',               &killbuffer,
  173.         CTLX|'N',               &nextwind,
  174.         CTLX|'P',               &prevwind,
  175.         CTLX|'Z',               &enlargewind,
  176.         META|CTRL|'H',          &delbword,
  177.         META|'!',               &reposition,
  178.         META|'.',               &setmark,
  179.         META|'>',               &gotoeob,
  180.         META|'<',               &gotobob,
  181.         META|'B',               &backword,
  182.         META|'C',               &capword,
  183.         META|'D',               &delfword,
  184.         META|'F',               &forwword,
  185.         META|'L',               &lowerword,
  186.         META|'U',               &upperword,
  187.         META|'V',               &backpage,
  188.         META|'W',               ©region,
  189.         META|0x7F,              &delbword,
  190.         0x7F,                   &backdel
  191. };
  192.  
  193. #define NKEYTAB (sizeof(keytab)/sizeof(keytab[0]))
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. #if RAINBOW
  203.  
  204. #include "rainbow.h"
  205.  
  206. /*
  207.  * Mapping table from the LK201 function keys to the internal EMACS character.
  208.  */
  209.  
  210. short lk_map[][2] = {
  211.         Up_Key,                         CTRL+'P',
  212.         Down_Key,                       CTRL+'N',
  213.         Left_Key,                       CTRL+'B',
  214.         Right_Key,                      CTRL+'F',
  215.         Shift+Left_Key,                 META+'B',
  216.         Shift+Right_Key,                META+'F',
  217.         Control+Left_Key,               CTRL+'A',
  218.         Control+Right_Key,              CTRL+'E',
  219.         Prev_Scr_Key,                   META+'V',
  220.         Next_Scr_Key,                   CTRL+'V',
  221.         Shift+Up_Key,                   META+'<',
  222.         Shift+Down_Key,                 META+'>',
  223.         Cancel_Key,                     CTRL+'G',
  224.         Find_Key,                       CTRL+'S',
  225.         Shift+Find_Key,                 CTRL+'R',
  226.         Insert_Key,                     CTRL+'Y',
  227.         Options_Key,                    CTRL+'D',
  228.         Shift+Options_Key,              META+'D',
  229.         Remove_Key,                     CTRL+'W',
  230.         Shift+Remove_Key,               META+'W',
  231.         Select_Key,                     CTRL+'@',
  232.         Shift+Select_Key,               CTLX+CTRL+'X',
  233.         Interrupt_Key,                  CTRL+'U',
  234.         Keypad_PF2,                     META+'L',
  235.         Keypad_PF3,                     META+'C',
  236.         Keypad_PF4,                     META+'U',
  237.         Shift+Keypad_PF2,               CTLX+CTRL+'L',
  238.         Shift+Keypad_PF4,               CTLX+CTRL+'U',
  239.         Keypad_1,                       CTLX+'1',
  240.         Keypad_2,                       CTLX+'2',
  241.         Do_Key,                         CTLX+'E',
  242.         Keypad_4,                       CTLX+CTRL+'B',
  243.         Keypad_5,                       CTLX+'B',
  244.         Keypad_6,                       CTLX+'K',
  245.         Resume_Key,                     META+'!',
  246.         Control+Next_Scr_Key,           CTLX+'N',
  247.         Control+Prev_Scr_Key,           CTLX+'P',
  248.         Control+Up_Key,                 CTLX+CTRL+'P',
  249.         Control+Down_Key,               CTLX+CTRL+'N',
  250.         Help_Key,                       CTLX+'=',
  251.         Shift+Do_Key,                   CTLX+'(',
  252.         Control+Do_Key,                 CTLX+')',
  253.         Keypad_0,                       CTLX+'Z',
  254.         Shift+Keypad_0,                 CTLX+CTRL+'Z',
  255.         Main_Scr_Key,                   CTRL+'C',
  256.         Keypad_Enter,                   CTLX+'!',
  257.         Exit_Key,                       CTLX+CTRL+'C',
  258.         Shift+Exit_Key,                 CTRL+'Z'
  259.         };
  260.  
  261. #define lk_map_size     (sizeof(lk_map)/2)
  262.  
  263. #endif
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272. main(argc, argv)
  273. char    *argv[];
  274. {
  275.         register int    c;
  276.         register int    f;
  277.         register int    n;
  278.         register int    mflag;
  279.         char            bname[NBUFN];
  280.  
  281.         strcpy(bname, "main");                  /* Work out the name of */
  282.         if (argc > 1)                           /* the default buffer.  */
  283.                 makename(bname, argv[1]);
  284.         edinit(bname);                          /* Buffers, windows.    */
  285.         vtinit();                               /* Displays.            */
  286.         if (argc > 1) {
  287.                 update();                       /* You have to update   */
  288.                 readin(argv[1]);                /* in case "[New file]" */
  289.         }
  290.         lastflag = 0;                           /* Fake last flags.     */
  291. loop:
  292.         update();                               /* Fix up the screen    */
  293.         c = getkey();
  294.         if (mpresf != FALSE) {
  295.                 mlerase();
  296.                 update();
  297.                 if (c == ' ')                   /* ITS EMACS does this  */
  298.                         goto loop;
  299.         }
  300.         f = FALSE;
  301.         n = 1;
  302.         if (c == (CTRL|'U')) {                  /* ^U, start argument   */
  303.                 f = TRUE;
  304.                 n = 4;                          /* with argument of 4 */
  305.                 mflag = 0;                      /* that can be discarded. */
  306.                 mlwrite("Arg: 4");
  307.                 while ((c=getkey()) >='0' && c<='9' || c==(CTRL|'U') || c=='-'){
  308.                         if (c == (CTRL|'U'))
  309.                                 n = n*4;
  310.                         /*
  311.                          * If dash, and start of argument string, set arg.
  312.                          * to -1.  Otherwise, insert it.
  313.                          */
  314.                         else if (c == '-') {
  315.                                 if (mflag)
  316.                                         break;
  317.                                 n = 0;
  318.                                 mflag = -1;
  319.                         }
  320.                         /*
  321.                          * If first digit entered, replace previous argument
  322.                          * with digit and set sign.  Otherwise, append to arg.
  323.                          */
  324.                         else {
  325.                                 if (!mflag) {
  326.                                         n = 0;
  327.                                         mflag = 1;
  328.                                 }
  329.                                 n = 10*n + c - '0';
  330.                         }
  331.                         mlwrite("Arg: %d", (mflag >=0) ? n : (n ? -n : -1));
  332.                 }
  333.                 /*
  334.                  * Make arguments preceded by a minus sign negative and change
  335.                  * the special argument "^U -" to an effective "^U -1".
  336.                  */
  337.                 if (mflag == -1) {
  338.                         if (n == 0)
  339.                                 n++;
  340.                         n = -n;
  341.                 }
  342.         }
  343.         if (c == (CTRL|'X'))                    /* ^X is a prefix       */
  344.                 c = CTLX | getctl();
  345.         if (kbdmip != NULL) {                   /* Save macro strokes.  */
  346.                 if (c!=(CTLX|')') && kbdmip>&kbdm[NKBDM-6]) {
  347.                         ctrlg(FALSE, 0);
  348.                         goto loop;
  349.                 }
  350.                 if (f != FALSE) {
  351.                         *kbdmip++ = (CTRL|'U');
  352.                         *kbdmip++ = n;
  353.                 }
  354.                 *kbdmip++ = c;
  355.         }
  356.         execute(c, f, n);                       /* Do it.               */
  357.         goto loop;
  358. }
  359.  
  360. /*
  361.  * Initialize all of the buffers and windows. The buffer name is passed down
  362.  * as an argument, because the main routine may have been told to read in a
  363.  * file by default, and we want the buffer name to be right.
  364.  */
  365. edinit(bname)
  366. char    bname[];
  367. {
  368.         register BUFFER *bp;
  369.         register WINDOW *wp;
  370.  
  371.         bp = bfind(bname, TRUE, 0);             /* First buffer         */
  372.         blistp = bfind("[List]", TRUE, BFTEMP); /* Buffer list buffer   */
  373.         wp = (WINDOW *) malloc(sizeof(WINDOW)); /* First window         */
  374.         if (bp==NULL || wp==NULL || blistp==NULL)
  375.                 exit(1);
  376.         curbp  = bp;                            /* Make this current    */
  377.         wheadp = wp;
  378.         curwp  = wp;
  379.         wp->w_wndp  = NULL;                     /* Initialize window    */
  380.         wp->w_bufp  = bp;
  381.         bp->b_nwnd  = 1;                        /* Displayed.           */
  382.         wp->w_linep = bp->b_linep;
  383.         wp->w_dotp  = bp->b_linep;
  384.         wp->w_doto  = 0;
  385.         wp->w_markp = NULL;
  386.         wp->w_marko = 0;
  387.         wp->w_toprow = 0;
  388.         wp->w_ntrows = term.t_nrow-1;           /* "-1" for mode line.  */
  389.         wp->w_force = 0;
  390.         wp->w_flag  = WFMODE|WFHARD;            /* Full.                */
  391. }
  392.         
  393. /*
  394.  * This is the general command execution routine. It handles the fake binding
  395.  * of all the keys to "self-insert". It also clears out the "thisflag" word,
  396.  * and arranges to move it to the "lastflag", so that the next command can
  397.  * look at it. Return the status of command.
  398.  */
  399. execute(c, f, n)
  400. {
  401.         register KEYTAB *ktp;
  402.         register int    status;
  403.  
  404.         ktp = &keytab[0];                       /* Look in key table.   */
  405.         while (ktp < &keytab[NKEYTAB]) {
  406.                 if (ktp->k_code == c) {
  407.                         thisflag = 0;
  408.                         status   = (*ktp->k_fp)(f, n);
  409.                         lastflag = thisflag;
  410.                         return (status);
  411.                 }
  412.                 ++ktp;
  413.         }
  414.  
  415.         /*
  416.          * If a space was typed, fill column is defined, the argument is non-
  417.          * negative, and we are now past fill column, perform word wrap.
  418.          */
  419.         if (c == ' ' && fillcol > 0 && n>=0 && getccol(FALSE) > fillcol)
  420.                 wrapword();
  421.  
  422.         if ((c>=0x20 && c<=0x7E)                /* Self inserting.      */
  423.         ||  (c>=0xA0 && c<=0xFE)) {
  424.                 if (n <= 0) {                   /* Fenceposts.          */
  425.                         lastflag = 0;
  426.                         return (n<0 ? FALSE : TRUE);
  427.                 }
  428.                 thisflag = 0;                   /* For the future.      */
  429.                 status   = linsert(n, c);
  430.                 lastflag = thisflag;
  431.                 return (status);
  432.         }
  433.         lastflag = 0;                           /* Fake last flags.     */
  434.         return (FALSE);
  435. }
  436.  
  437. /*
  438.  * Read in a key.
  439.  * Do the standard keyboard preprocessing. Convert the keys to the internal
  440.  * character set.
  441.  */
  442. getkey()
  443. {
  444.         register int    c;
  445.  
  446.         c = (*term.t_getchar)();
  447.  
  448. #if RAINBOW
  449.  
  450.         if (c & Function_Key)
  451.                 {
  452.                 int i;
  453.  
  454.                 for (i = 0; i < lk_map_size; i++)
  455.                         if (c == lk_map[i][0])
  456.                                 return lk_map[i][1];
  457.                 }
  458.         else if (c == Shift + 015) return CTRL | 'J';
  459.         else if (c == Shift + 0x7F) return META | 0x7F;
  460. #endif
  461.  
  462.         if (c == METACH) {                      /* Apply M- prefix      */
  463.                 c = getctl();
  464.                 return (META | c);
  465.         }
  466.  
  467.         if (c>=0x00 && c<=0x1F)                 /* C0 control -> C-     */
  468.                 c = CTRL | (c+'@');
  469.         return (c);
  470. }
  471.  
  472. /*
  473.  * Get a key.
  474.  * Apply control modifications to the read key.
  475.  */
  476. getctl()
  477. {
  478.         register int    c;
  479.  
  480.         c = (*term.t_getchar)();
  481.         if (c>='a' && c<='z')                   /* Force to upper       */
  482.                 c -= 0x20;
  483.         if (c>=0x00 && c<=0x1F)                 /* C0 control -> C-     */
  484.                 c = CTRL | (c+'@');
  485.         return (c);
  486. }
  487.  
  488. /*
  489.  * Fancy quit command, as implemented by Norm. If the current buffer has
  490.  * changed do a write current buffer and exit emacs, otherwise simply exit.
  491.  */
  492. quickexit(f, n)
  493. {
  494.         if ((curbp->b_flag&BFCHG) != 0          /* Changed.             */
  495.         && (curbp->b_flag&BFTEMP) == 0)         /* Real.                */
  496.                 filesave(f, n);
  497.         quit(f, n);                             /* conditionally quit   */
  498. }
  499.  
  500. /*
  501.  * Quit command. If an argument, always quit. Otherwise confirm if a buffer
  502.  * has been changed and not written out. Normally bound to "C-X C-C".
  503.  */
  504. quit(f, n)
  505. {
  506.         register int    s;
  507.  
  508.         if (f != FALSE                          /* Argument forces it.  */
  509.         || anycb() == FALSE                     /* All buffers clean.   */
  510.         || (s=mlyesno("Quit")) == TRUE) {       /* User says it's OK.   */
  511.                 vttidy();
  512.                 exit(GOOD);
  513.         }
  514.         return (s);
  515. }
  516.  
  517. /*
  518.  * Begin a keyboard macro.
  519.  * Error if not at the top level in keyboard processing. Set up variables and
  520.  * return.
  521.  */
  522. ctlxlp(f, n)
  523. {
  524.         if (kbdmip!=NULL || kbdmop!=NULL) {
  525.                 mlwrite("Not now");
  526.                 return (FALSE);
  527.         }
  528.         mlwrite("[Start macro]");
  529.         kbdmip = &kbdm[0];
  530.         return (TRUE);
  531. }
  532.  
  533. /*
  534.  * End keyboard macro. Check for the same limit conditions as the above
  535.  * routine. Set up the variables and return to the caller.
  536.  */
  537. ctlxrp(f, n)
  538. {
  539.         if (kbdmip == NULL) {
  540.                 mlwrite("Not now");
  541.                 return (FALSE);
  542.         }
  543.         mlwrite("[End macro]");
  544.         kbdmip = NULL;
  545.         return (TRUE);
  546. }
  547.  
  548. /*
  549.  * Execute a macro.
  550.  * The command argument is the number of times to loop. Quit as soon as a
  551.  * command gets an error. Return TRUE if all ok, else FALSE.
  552.  */
  553. ctlxe(f, n)
  554. {
  555.         register int    c;
  556.         register int    af;
  557.         register int    an;
  558.         register int    s;
  559.  
  560.         if (kbdmip!=NULL || kbdmop!=NULL) {
  561.                 mlwrite("Not now");
  562.                 return (FALSE);
  563.         }
  564.         if (n <= 0) 
  565.                 return (TRUE);
  566.         do {
  567.                 kbdmop = &kbdm[0];
  568.                 do {
  569.                         af = FALSE;
  570.                         an = 1;
  571.                         if ((c = *kbdmop++) == (CTRL|'U')) {
  572.                                 af = TRUE;
  573.                                 an = *kbdmop++;
  574.                                 c  = *kbdmop++;
  575.                         }
  576.                         s = TRUE;
  577.                 } while (c!=(CTLX|')') && (s=execute(c, af, an))==TRUE);
  578.                 kbdmop = NULL;
  579.         } while (s==TRUE && --n);
  580.         return (s);
  581. }
  582.  
  583. /*
  584.  * Abort.
  585.  * Beep the beeper. Kill off any keyboard macro, etc., that is in progress.
  586.  * Sometimes called as a routine, to do general aborting of stuff.
  587.  */
  588. ctrlg(f, n)
  589. {
  590.         (*term.t_beep)();
  591.         if (kbdmip != NULL) {
  592.                 kbdm[0] = (CTLX|')');
  593.                 kbdmip  = NULL;
  594.         }
  595.         return (ABORT);
  596. }
  597.  
  598.  
  599.